From: Florian Müllner Date: Fri, 5 Dec 2025 08:25:30 +0000 (+0100) Subject: workspaceAnimation: Split out BaseWorkspaceGroup X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~55^2^2~15 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=7914249ab3770a9d3a107010868d3946be6e62aa;p=gnome-shell.git workspaceAnimation: Split out BaseWorkspaceGroup Since we started to show DESKTOP windows as part of the background during the workspace animation, we need to track both the windows relevant for the monitor/workspace and DESKTOP windows. We are about to split out the background handling into its own class. To prepare for this, split out a BaseWorkspaceGroup class that handles the basic "create clones of relevant windows and track them" functionality common to both cases. Part-of: (cherry picked from commit 96be47933ffdc2c0645aae155ce1b2cf6b16593a) --- diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js index 11cd7eedd..3c1e7d916 100644 --- a/js/ui/workspaceAnimation.js +++ b/js/ui/workspaceAnimation.js @@ -14,10 +14,10 @@ import * as Main from './main.js'; const WINDOW_ANIMATION_TIME = 250; export const WORKSPACE_SPACING = 100; -export const WorkspaceGroup = GObject.registerClass( -class WorkspaceGroup extends Clutter.Actor { - _init(workspace, monitor, movingWindow) { - super._init({ +export const BaseWorkspaceGroup = GObject.registerClass( +class BaseWorkspaceGroup extends Clutter.Actor { + constructor(workspace, monitor) { + super({ width: monitor.width, height: monitor.height, clip_to_allocation: true, @@ -25,68 +25,20 @@ class WorkspaceGroup extends Clutter.Actor { this._workspace = workspace; this._monitor = monitor; - this._movingWindow = movingWindow; this._windowRecords = []; - if (this._workspace) { - this._background = new Meta.BackgroundGroup(); - - this.add_child(this._background); - - this._bgManager = new Background.BackgroundManager({ - container: this._background, - monitorIndex: this._monitor.index, - controlPosition: false, - }); - this._createDesktopWindows(); - } - + this._createBackground(); this._createWindows(); this.connect('destroy', this._onDestroy.bind(this)); - global.display.connectObject('restacked', - this._syncStacking.bind(this), this); } get workspace() { return this._workspace; } - _shouldShowWindow(window) { - if (!window.showing_on_its_workspace() || this._isDesktopWindow(window)) - return false; - - if (window.is_override_redirect()) - return false; - - if (!this._windowIsOnThisMonitor(window)) - return false; - - const isSticky = - window.is_on_all_workspaces() || window === this._movingWindow; - - // No workspace means we should show windows that are on all workspaces - if (!this._workspace) - return isSticky; - - // Otherwise only show windows that are (only) on that workspace - return !isSticky && window.located_on_workspace(this._workspace); - } - - _syncStacking() { - const windowActors = global.get_window_actors().filter(w => - this._shouldShowWindow(w.meta_window)); - - let lastRecord; - const bottomActor = this._background ?? null; - - for (const windowActor of windowActors) { - const record = this._windowRecords.find(r => r.windowActor === windowActor); - - this.set_child_above_sibling(record.clone, - lastRecord ? lastRecord.clone : bottomActor); - lastRecord = record; - } + _shouldShowWindow(_window) { + throw new GObject.NotImplementedError(); } _isDesktopWindow(metaWindow) { @@ -99,11 +51,7 @@ class WorkspaceGroup extends Clutter.Actor { return intersects; } - _createDesktopWindows() { - const desktopActors = global.get_window_actors().filter(w => { - return this._isDesktopWindow(w.meta_window) && this._windowIsOnThisMonitor(w.meta_window); - }); - desktopActors.map(a => this._createClone(a)).forEach(clone => this._background.add_child(clone)); + _createBackground() { } _createWindows() { @@ -140,6 +88,81 @@ class WorkspaceGroup extends Clutter.Actor { _onDestroy() { this._removeWindows(); + } +}); + +export const WorkspaceGroup = GObject.registerClass( +class WorkspaceGroup extends BaseWorkspaceGroup { + constructor(workspace, monitor, movingWindow) { + super(workspace, monitor); + + this._movingWindow = movingWindow; + + global.display.connectObject('restacked', + () => this._syncStacking(), this); + } + + _shouldShowWindow(window) { + if (!window.showing_on_its_workspace() || this._isDesktopWindow(window)) + return false; + + if (window.is_override_redirect()) + return false; + + if (!this._windowIsOnThisMonitor(window)) + return false; + + const isSticky = + window.is_on_all_workspaces() || window === this._movingWindow; + + // No workspace means we should show windows that are on all workspaces + if (!this._workspace) + return isSticky; + + // Otherwise only show windows that are (only) on that workspace + return !isSticky && window.located_on_workspace(this._workspace); + } + + _syncStacking() { + const windowActors = global.get_window_actors().filter(w => + this._shouldShowWindow(w.meta_window)); + + let lastRecord; + const bottomActor = this._background ?? null; + + for (const windowActor of windowActors) { + const record = this._windowRecords.find(r => r.windowActor === windowActor); + + this.set_child_above_sibling(record.clone, + lastRecord ? lastRecord.clone : bottomActor); + lastRecord = record; + } + } + + _createBackground() { + if (!this._workspace) + return; + + this._background = new Meta.BackgroundGroup(); + this.add_child(this._background); + + this._bgManager = new Background.BackgroundManager({ + container: this._background, + monitorIndex: this._monitor.index, + controlPosition: false, + }); + this._createDesktopWindows(); + } + + _createDesktopWindows() { + const desktopActors = global.get_window_actors().filter(w => { + return this._isDesktopWindow(w.meta_window) && this._windowIsOnThisMonitor(w.meta_window); + }); + desktopActors.map(a => this._createClone(a)).forEach(clone => this._background.add_child(clone)); + } + + _onDestroy() { + super._onDestroy(); if (this._workspace) this._bgManager.destroy();